#include <iostream>
#include <math.h>

#include "Fit/RooTruncatedPolynomial.h"
#include "RooAbsReal.h"
#include "RooFit.h"

RooTruncatedPolynomial::RooTruncatedPolynomial(const char* name, const char* title, RooAbsReal& _x,
                                               RooAbsReal& _m0, RooAbsReal& _a, RooAbsReal& _b,
                                               RooAbsReal& _c) :
  RooAbsPdf(name, title),
  x("x", "x", this, _x),
  m0("m0", "m0", this, _m0),
  a("a", "a", this, _a),
  b("b", "b", this, _b),
  c("c", "c", this, _c)
{}

RooTruncatedPolynomial::RooTruncatedPolynomial(const RooTruncatedPolynomial& other,
                                               const char*                   name) :
  RooAbsPdf(other, name),
  x("x", this, other.x),
  m0("m_{0}", this, other.m0),
  a("a", this, other.a),
  b("b", this, other.b),
  c("c", this, other.c)
{}

// (m - m_0)^a e^{-bm - cm^2}
Double_t RooTruncatedPolynomial::evaluate() const
{
  return pow(x - m0, a) * exp(-b * x - c * x * x);
}